package com.web;

import com.beans.User;
import com.service.UserService;
import com.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user.login")
public class UserServlet extends BaseServlet {

    private UserService userService = new UserServiceImpl();

    public void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String userpassword = req.getParameter("userpassword");
        User user = new User(username, userpassword);
        boolean login = userService.login(user);
        if (login){
            System.out.println("登录成功");
        }else {
            System.out.println("登录失败");
        }
    }

}
